using UnityEngine;

public class BallFlight
{
	public float mass = 0.0027f;

	public float radius = 0.02f;

	public FlightPool pool;

	public Vector3 gravity = Physics.gravity;

	public FlightParams initialConditions { get; protected set; }

	public float flightTime { get; set; }

	public float apexTime
	{
		get
		{
			if (gravity.y == 0f)
			{
				return 0f;
			}
			return (0f - initialConditions.velocity.y) / gravity.y;
		}
	}

	public virtual void ReturnToPool()
	{
		if (pool != null)
		{
			pool.ReturnFlightToPool(this);
		}
	}

	public virtual void SetInitialConditions(FlightParams initialConditions, PhysicsBall ball)
	{
	}

	public virtual void Reset()
	{
	}

	public virtual void Update(float deltaTime)
	{
	}

	public FlightParams FlightParams()
	{
		FlightParams result = default(FlightParams);
		result.position = Position();
		result.velocity = Velocity();
		result.angularVelocity = AngularVelocity();
		return result;
	}

	public virtual Vector3 Position()
	{
		return Vector3.zero;
	}

	public virtual Vector3 Velocity()
	{
		return Vector3.zero;
	}

	public virtual Vector3 AngularVelocity()
	{
		return Vector3.zero;
	}

	public virtual Vector3 PositionAt(float time)
	{
		return Vector3.zero;
	}

	public virtual Vector3 VelocityAt(float time)
	{
		return Vector3.zero;
	}

	public virtual Vector3 AngularVelocityAt(float time)
	{
		return Vector3.zero;
	}

	public virtual float GetMaxTimeWhenCrossesPlane(float height, float duration, float symDelta)
	{
		Vector3 vector = PositionAt(0f);
		float result = -1f;
		for (float num = symDelta; num < duration; num += symDelta)
		{
			Vector3 vector2 = PositionAt(num);
			float num2 = vector.y;
			float num3 = vector2.y;
			float num4 = num - symDelta;
			float num5 = num;
			if (num2 > num3)
			{
				float num6 = num5;
				num5 = num4;
				num4 = num6;
				num6 = num3;
				num3 = num2;
				num2 = num6;
			}
			if (num2 <= height && num3 >= height)
			{
				result = Mathf.Lerp(num4, num5, Mathf.InverseLerp(num2, num3, height));
			}
			vector = vector2;
		}
		return result;
	}

	public virtual FlightParams GetParamsAtHeight(float height)
	{
		return default(FlightParams);
	}

	public virtual void RollBackToHeight(float height)
	{
	}

	public virtual float GetTimeToRollBackToHeight(float height)
	{
		return 0f;
	}
}
